﻿using Infrastructure;
using Launcher.Modules;

using Microsoft.Practices.Prism.Events;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.UnityExtensions;
using Microsoft.Practices.Unity;

using System;
using System.Windows;

namespace Launcher
{
    class BootStrapper : UnityBootstrapper
    {
        protected override DependencyObject CreateShell()
        {
            return Container.Resolve<Shell>();
        }

        protected override void InitializeShell()
        {
            Application.Current.MainWindow = Shell as Window;
            Application.Current.MainWindow.Show();
        }

        protected override void InitializeModules()
        {
            Type type = typeof(StartModule);
            ModuleCatalog.AddModule(new ModuleInfo
            {
                ModuleName = type.Name,
                ModuleType = type.AssemblyQualifiedName,
                InitializationMode = InitializationMode.WhenAvailable
            });

            base.InitializeModules();

            EventAggregator evenAggregator = Container.Resolve<EventAggregator>();
            evenAggregator.GetEvent<StartEvent>().Publish(null);
        }
    }
}
